<?php
	if(!defined("IN_APP"))
	{
		exit;
	}
	
	if(!adminpermission('Y','Y100003'))
	{
		echo '无权查看!';
		exit;
	}
	
	$method = getParam('m','get','list');
	
	$parm = requestArrayParm($_REQUEST);
	
	
	if($method == 'chuliTixian')
	{
		//获取返利记录
		if(!empty($parm['id']))
		{
			$info = _Tixian::getTixianInfo(array('id'=>$parm['id']));
			if($info)
			{
				$info['user'] = _User::getUserInfo(array('id'=>$info['uid']));
				
				unset($wheres);
				$wheres['uid'] = $info['uid'];
				$info['account'] = _Account_number::getAccount_numberList($wheres);
			}
			else
			{
				header("Location:".SITE_URL.'admin.php?a=tixianM');
				exit;
			}
		}
		else
		{
			header("Location:".SITE_URL.'admin.php?a=tixianM');
			exit;
		}
		
		
		
		include renderTemplate('admin/tixian/info');
	}
	
	if($method == 'list')
	{
		$typearr['name'] = '姓名';
		$typearr['phone'] = '手机号';
		
		$fTitle = "提现管理";
		$sTitle = "提现列表";
		
		$search = array();
		
		if($parm['start'] && $parm['end'])
		{
			$between['start'] = strtotime($parm['start']);
			
			$between['end'] = strtotime($parm['end']);
		}
		
		if($parm['status'])
		{
			$search['status'] = $parm['status'];
		}
		
		if($parm['keyword'])
		{
			$search['phone'] = $parm['keyword'];
		}
		
		$page = $pages['page'] = getParam('page','request','1');
		
		$pages['rows'] = 20;
		
		$sort['status'] = 'asc';
		
		$sort['addtime'] = 'desc';
		
		$resData = _Tixian::getTixianList($search, $pages, $between,$sort);
		
		//查询对应的数据
		
		foreach ($resData['list']  as $key => $value)
		{
			//获取用户
			$value['user'] = _User::getUserInfo(array('id'=>$value['uid']));
			
			$value['opinfo'] = _OpLog::getLastOpLog(array('table'=>'tixian','union_id'=>$value['id']));
			
			$list[] = $value;
		}
		
		$pageurl = SITE_URL.'admin.php?'.set_URL_Param(get_URL_Param());
	
		$pagetotal = $resData["pages"];
		
		include renderTemplate('admin/tixian/list');
	}